package com.string.test;

import java.util.Scanner;

public class Login {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        boolean signal = false;
        for (int i = 0; i < 3; i++) {
            System.out.println("请输入您的用户名：");
            String name = sc.next();
            System.out.println("请输入您的密码：");
            String pwd = sc.next();
            signal = compare(name, pwd);
            if (signal) {
                System.out.println("登录成功！");
                break;
            } else System.out.println("用户名或密码不正确！还剩" + (2 - i) + "次机会");
            if (i == 2) {
                System.out.println("账户被锁定，无法继续使用！");
            }
        }
    }

    public static boolean compare(String name, String pwd) {
        String real_name = "admin";
        String real_pwd = "123456";
        if (name.equals(real_name) && pwd.equals(real_pwd)) {
            return true;
        }
        return false;
    }
}
